 <?php
 
// Server IP address
$address = "127.0.0.1";
 
// Port to listen
$port = 4321;
 
$mysock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
 
socket_bind($mysock,$address, $port) or die('Could not bind to address'); 
socket_listen($mysock, 5);
$client = socket_accept($mysock);
 
// read 1024 bytes from client
$input = socket_read($client, 1024);
 
// write received data to the file

socket_close($client);
socket_close($mysock);

?> 